//
//  BaseHideNaviViewController.m
//  XV
//
//  Created by apple on 25/06/2019.
//  Copyright © 2019 XR. All rights reserved.
//

#import "BaseHideNaviViewController.h"

@interface BaseHideNaviViewController ()

@property (nonatomic, strong) UIButton* backButton;

@end

@implementation BaseHideNaviViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self.view addSubview:self.backButton];
    [_backButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(LL_StatusBarHeight+12);
    }];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:animated];
    
    [self.view bringSubviewToFront:self.backButton];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:animated];
}


- (UIButton *)backButton {
    if (_backButton == nil) {
        _backButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_backButton setImage:[UIImage imageNamed:@"icon_black_back"] forState:UIControlStateNormal];
        [_backButton addTarget:self action:@selector(backButtonDidClick) forControlEvents:UIControlEventTouchUpInside];
    }
    return _backButton;
}

- (void)backButtonDidClick
{
    [self.navigationController popViewControllerAnimated:YES];
}

@end
